package gui;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class EqualsTest extends JFrame {

	private JPanel contentPane;
	private JButton btnEqualtest;
	private JButton btnEqualtest_1;
	private JScrollPane scrollPane;
	private JTextArea result;
	Object o1 = new Object();

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					EqualsTest frame = new EqualsTest();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public EqualsTest() {
		setTitle("EqualsTest Program");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 379, 302);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		contentPane.add(getBtnEqualtest());
		contentPane.add(getBtnEqualtest_1());
		contentPane.add(getScrollPane());
	}

	private JButton getBtnEqualtest() {
		if (btnEqualtest == null) {
			btnEqualtest = new JButton("EqualTest1");
			btnEqualtest.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					
					Object o2 = new Object();
					if(o1.equals(o2)) result.setText("o1 and o2 are same Object");
					else result.setText("o1 and o2 are different Object");
					
				}
			});
			btnEqualtest.setBounds(12, 10, 115, 50);
		}
		return btnEqualtest;
	}
	private JButton getBtnEqualtest_1() {
		if (btnEqualtest_1 == null) {
			btnEqualtest_1 = new JButton("EqualTest2");
			btnEqualtest_1.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					Object o3 = o1;
					if(o1.equals(o3)) result.setText("o1 and o3 are same Object");
					else result.setText("o1 and o3 are different Object");
				}
			});
			btnEqualtest_1.setBounds(12, 70, 115, 50);
		}
		return btnEqualtest_1;
	}
	private JScrollPane getScrollPane() {
		if (scrollPane == null) {
			scrollPane = new JScrollPane();
			scrollPane.setBounds(133, 10, 218, 244);
			scrollPane.setViewportView(getResult());
		}
		return scrollPane;
	}
	private JTextArea getResult() {
		if (result == null) {
			result = new JTextArea();
		}
		return result;
	}
}
